//=============================================================================

#include "helper.hpp"

namespace KEG
{

std::string FilenameToString( const std::string& filename )
{
   std::ifstream fin(filename.c_str());
   if( !fin ) return std::string("");
   return std::string((std::istreambuf_iterator<char>(fin)),
                        std::istreambuf_iterator<char>());
}

std::string FileToString( std::ifstream& fin )
{
   return std::string((std::istreambuf_iterator<char>(fin)),
                        std::istreambuf_iterator<char>());
}

void FilenameToStringstream( std::istringstream& strstr,
                                const std::string& filename )
{
    std::ifstream fin(filename.c_str());
    if( !fin ) return;
    strstr.str( FileToString( fin ) );
}

void FileToStringstream( std::istringstream& strstr,
                            std::ifstream& fin )
{
    strstr.str( FileToString( fin ) );
}

}
